package workers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

import messaging.IMessagingHandler;
import messaging.JMSMessagingConstants;
import messaging.SoftwareDevelopmentMessagingHandler;
import model.Software;
import workerUIs.StepFrame;
import workflow.step.UIImplementationStep;

public class UIStepWorker extends AbstractStepSwingWorker {
	
	public UIStepWorker(StepFrame frame,
			IMessagingHandler<Software> messagingHandler) {
		super(frame, messagingHandler);
	}

	@Override
	protected void doStep(Software software) {
		new UIImplementationStep().doStep(this.software);
	}	
	
	public static void main(String[] args) {
		Logger logger = Logger.getLogger(ArchitectureStepWorker.class.getCanonicalName());
		try
		{
			final StepFrame uiFrame = new StepFrame("Step3b: GUI implementation", 800, 400);
			List<String> uiInputQueues = new ArrayList<String>();
			uiInputQueues.add(JMSMessagingConstants.ARCH_OUTPUT_UI_INPUT);
			List<String> uiOutputQueues = new ArrayList<String>();
			uiOutputQueues.add(JMSMessagingConstants.UI_OUTPUT_INTEGRATION_INPUT);
			final IMessagingHandler<Software> messagingHandler = new SoftwareDevelopmentMessagingHandler(uiFrame, uiInputQueues, uiOutputQueues);
			uiFrame.getNextButton().addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent e) {
					new UIStepWorker(uiFrame, messagingHandler).execute();				
				}
			});			

		}
		catch (Exception e)
		{
			logger.log(Level.SEVERE, "Error during initialization: ", e);
		}
	}


}
